package com.yinhe.music.yhmusic.album;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.yinhe.music.common.GlideHelper.GlideHelper;
import com.yinhe.music.yhmusic.R;
import com.yinhe.music.yhmusic.model.AlbumInfo;

import butterknife.BindView;
import butterknife.ButterKnife;

public class AlbumDetailActivity extends Activity implements View.OnClickListener {

    @BindView(R.id.album_image)
    ImageView albumImage;
    @BindView(R.id.album_name)
    TextView albumName;
    @BindView(R.id.album_text)
    TextView albumText;
    @BindView(R.id.close)
    ImageView close;

    private String sAlbumName, sAlbumDetail, sAlbumImage;
    private AlbumInfo albumInfo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_album_detail);
        ButterKnife.bind(this);
        getAlbum();
        initView();
    }

    private void getAlbum() {
        if (getIntent() != null) {
            albumInfo = (AlbumInfo) getIntent().getSerializableExtra("album");
            sAlbumName = albumInfo.getAlbumName();
            sAlbumImage = albumInfo.getImage();
            sAlbumDetail = albumInfo.getIntro();
        }
    }

    private void initView() {
        GlideHelper.setImageResource(albumImage, sAlbumImage);
        albumName.setText(sAlbumName);
        albumText.setText(sAlbumDetail);
        close.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.close) finish();
    }
}
